package com.key.service.impl;

import com.key.common.R;
import com.key.entity.Assets;
import com.key.entity.SysUser;
import com.key.entity.SysUser;
import com.key.mapper.IndexMapper;
import com.key.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author: li
 * @CreateTime: 2023-02-20  08:53
 */
@Service
public class IndexServiceImpl implements IndexService {

    @Autowired
    IndexMapper indexMapper;


    @Override
    public SysUser showUserInfoByUserName(String userName) {
        SysUser sysUser = indexMapper.selectUserInfoByUserName(userName);
        return sysUser;
    }

    @Override
    public List<Map<String,Object>> showUserAssetsState(Integer assetsManagerId) {

        List<Map<String, Object>> mapList = indexMapper.selectUserAssetsState(assetsManagerId);

        return mapList;
    }

    @Override
    public List<Map<String, Object>> showUserInventoryState(Integer assetsManagerId) {

        List<Map<String, Object>> mapList = indexMapper.selectUserInventoryState(assetsManagerId);
        return mapList;
    }

    @Override
    public R showUserSignAssetsState(Integer assetsManagerId) {

        R r = new R();
        try {
            List<Map<String, Object>> mapList = indexMapper.selectUserISignAssetsState(assetsManagerId);
            r.setCode(200);
            r.setMsg("success");
            r.setData(mapList);
        } catch (Exception e) {
            r.setCode(500);
            r.setMsg("系统开小差，请联系管理员！");
        }
        return r;
    }
}
